package com.greensam.pixelengine.pojo.entity;

import com.greensam.pixelengine.pojo.base.BaseEntity;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Comment;

/**
 * @author Ma Chengrui
 * @since 2025/9/18 17:49
 */
@Getter
@Setter
@Entity
@Table(name = "space_user_rel",
        indexes = {
                @Index(name = "idx_space_id", columnList = "space_id"),
                @Index(name = "idx_user_id", columnList = "user_id"),
                @Index(name = "idx_role_id", columnList = "role_id"),
        },
        uniqueConstraints = {
                @UniqueConstraint(name = "uk_user_role", columnNames = {"user_id", "role_id"})
        })
@Comment("空间-用户关联表")
public class SpaceUserPo extends BaseEntity {

    @Column(nullable = false, length = 20)
    @Comment("空间id")
    private Long spaceId;

    @Column(nullable = false, length = 128)
    @Comment("空间名称")
    private String spaceName;

    @Column(nullable = false, length = 20)
    @Comment("用户id")
    private Long userId;

    @Column(nullable = false, length = 128)
    @Comment("用户名称")
    private String userName;

    @Column(nullable = false, length = 20)
    @Comment("角色id")
    private Long roleId;

    @Column(nullable = false, length = 32)
    @Comment("角色标识")
    private String roleCode;

    @Column(nullable = false, length = 128)
    @Comment("角色名称")
    private String roleName;

}
